﻿CREATE PROCEDURE [ProductFeedback].[GetProductReviewAttributeCategoryRelations]
	@TenantId uniqueidentifier,
	@CatalogId [ProductFeedback].[TCatalogId],
	@CategoryId [ProductFeedback].[TCategoryId]
AS

-- 1st
SELECT
	PRACA.AttributeId,
	PRACA.StartDate,
	PRACA.FinishDate,
	PRACA.DisplayOrder
FROM
	ProductReviewAttributeCategoryAssociation PRACA
	INNER JOIN ProductReviewAttribute PRA ON PRACA.TenantId = PRA.TenantId AND PRACA.AttributeId = PRA.AttributeId
WHERE
	PRACA.CatalogId = @CatalogId
	AND PRACA.CategoryId = @CategoryId
	AND PRA.TenantId = @TenantId

-- 2nd
SELECT
	PRACD.AttributeId,
	PRACD.StartDate,
	PRACD.FinishDate
FROM
	ProductReviewAttributeCategoryDisassociation PRACD
	INNER JOIN ProductReviewAttribute PRA ON PRACD.TenantId = PRA.TenantId AND PRACD.AttributeId = PRA.AttributeId
WHERE
	PRACD.CatalogId = @CatalogId
	AND PRACD.CategoryId = @CategoryId
	AND PRA.TenantId = @TenantId
